<template>
  <a-card :bordered="false">
   <div class="table-page-search-wrapper">
         <a-form layout="inline" @keyup.enter.native="searchQuery">
           <a-row :gutter="24">
             <a-col :xl="6" :lg="7" :md="8" :sm="24">
               <a-form-item label="纳税人识别号">
                 <j-input placeholder="请输入纳税人识别号" v-model="queryParam.creditCode"></j-input>
               </a-form-item>
             </a-col>
             <a-col :xl="6" :lg="7" :md="8" :sm="24">
               <a-form-item label="个体户姓名">
                 <j-input placeholder="请输入个体户姓名" v-model="queryParam.traname"></j-input>
               </a-form-item>
             </a-col>
             <a-col :xl="6" :lg="7" :md="8" :sm="24">
               <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                 <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                 <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
               </span>
             </a-col>
           </a-row>
         </a-form>
       </div>
    <a-modal
      title="发票预览"
      :visible="visibleFp"
      width="1200px"
      cancelText="关闭"
      @cancel="HzClose"
    >
      <div  id="hz" style="width:1160px;height:475px;overflow-y:auto;">
        <iframe style="width: 100%;height: 100%;" :src="fpImgUrl"></iframe>
      </div>

      <template slot="footer">
        <a-button @click="HzClose">关闭</a-button>
      </template>

    </a-modal>
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('已开具发票列表')">导出</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">详情</a>
          <a-divider type="vertical"/>
          <a @click="pdf(record)">发票预览</a>
        </span>
      </a-table>
    </div>

    <lhyg-reg-invoice-modal ref="modalForm" @ok="modalFormOk"></lhyg-reg-invoice-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { FormTypes } from '@/utils/JEditableTableUtil'
  import LhygRegInvoiceModal from './modules/LhygRegInvoiceModal'
  import JInput from '@/components/jeecg/JInput'

  export default {
    name: 'LhygRegInvoiceList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      LhygRegInvoiceModal,JInput
    },
    data () {
      return {
        description: '个人给平台开票的发票主表管理页面',
        visibleFp:false,
        fpImgUrl:'',
        // 表头
        columns: [
          {
             title:'发票代码',
             align:"center",
             dataIndex: 'invoiceCode'
          },
          {
             title:'发票号码',
             align:"center",
             dataIndex: 'invoiceNo'
          },
          {
             title:'个体户姓名',
             align:"center",
             dataIndex: 'traname'
           },
          {
            title:'纳税人识别号',
            align:"center",
            dataIndex: 'creditCode'
          },
          {
            title:'核定行业',
            align:"center",
            dataIndex: 'industryCode_dictText'
           },
           {
             title:'开票时间',
             align:"center",
             dataIndex: 'createTime',
             customRender:function (text) {
                 return !text?"":(text.length>10?text.substr(0,10):text)
              }
           },
           {
            title:'价税合计',
            align:"center",
            dataIndex: 'invoiceJe'
          },
          {
            title:'开票税额',
            align:"center",
            dataIndex: 'invoiceSe'
          },
          {
            title:'开票金额',
            align:"center",
            customRender:function (text,record,index) {
                  return record.invoiceJe - record.invoiceSe
              }
          },
          {
            title:'主管税务所',
            align:"center",
            dataIndex: 'taxOffice'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/gsinvoice/lhygRegInvoice/list",
          delete: "/gsinvoice/lhygRegInvoice/delete",
          deleteBatch: "/gsinvoice/lhygRegInvoice/deleteBatch",
          exportXlsUrl: "/gsinvoice/lhygRegInvoice/exportXls",
          importExcelUrl: "gsinvoice/lhygRegInvoice/importExcel",

        },
        dictOptions:{},
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      pdf(record) {
        let that = this;
        that.fpImgUrl = record.fppdf;
        that.visibleFp = true;
      },
      HzClose(){
        this.visibleFp = false;
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>


